﻿@model IList<XCode.Membership.User>
@using NewLife;
@using NewLife.Web;
@using XCode;
@using NewLife.Cube;
@using XCode.Membership;
@{
    var fact = ViewBag.Factory as IEntityFactory;
    var page = ViewBag.Page as Pager;
    var fields = ViewBag.Fields as FieldCollection;
    var set = ViewBag.PageSetting as PageSetting ?? PageSetting.Global;
}

<table class="table table-bordered table-hover table-striped table-condensed mb-0">
    <thead class="bg-white fw-bold fs-6 border border-bottom-3 border-gray-200">
        <tr>
            @if (set.EnableSelect)
            {
                <th class="text-center min-w-5px"><input type="checkbox" id="chkAll" title="全选" /></th>
            }
            <th class="text-center min-w-50px"><a href="@Html.Raw(page.GetSortUrl("ID"))">编号</a></th>
            <th class="min-w-50px" title="名称。登录用户名"><a href="@Html.Raw(page.GetSortUrl("Name"))">名称</a></th>
            <th class="min-w-100px"><a href="@Html.Raw(page.GetSortUrl("DisplayName"))">昵称</a></th>
            <th class="text-center min-w-50px" title="性别。未知、男、女"><a href="@Html.Raw(page.GetSortUrl("Sex"))">性别</a></th>
            <th class="min-w-50px"><a href="@Html.Raw(page.GetSortUrl("Mail"))">邮件</a></th>
            <th class="min-w-50px"><a href="@Html.Raw(page.GetSortUrl("Mobile"))">手机</a></th>
            <th class="min-w-50px"><a href="@Html.Raw(page.GetSortUrl("DepartmentID"))">部门</a></th>
            <th class="min-w-100px"><a href="@Html.Raw(page.GetSortUrl("RoleID"))">角色</a></th>
            <th class="text-center min-w-50px"><a href="@Html.Raw(page.GetSortUrl("Online"))">在线</a></th>
            <th class="text-center min-w-50px"><a href="@Html.Raw(page.GetSortUrl("Enable"))">启用</a></th>
            <th class="text-right min-w-100px"><a href="@Html.Raw(page.GetSortUrl("Logins"))">登录次数</a></th>
            <th class="min-w-150px"><a href="@Html.Raw(page.GetSortUrl("LastLogin"))">最后登录</a></th>
            <th class="min-w-100px"><a href="@Html.Raw(page.GetSortUrl("LastLoginIP"))">最后IP</a></th>
            <th class="text-center min-w-50px">链接</th>
            <th class="text-center min-w-50px">日志</th>

            @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
            {
                <th class="text-center">操作</th>
            }
        </tr>
    </thead>
    <tbody class="border border-gray-300">
        @foreach (var entity in Model)
        {
            <tr>
                @if (set.EnableSelect)
                {
                    <td class="text-center"><input type="checkbox" name="keys" value="@entity.ID" /></td>
                }
                <td class="text-center">@entity.ID</td>
                <td>@entity.Name</td>
                <td>@entity.DisplayName</td>
                <td class="text-center">@entity.Sex</td>
                <td>@entity.Mail</td>
                <td>@entity.Mobile</td>
                <td><a href="Department?ID=@entity.DepartmentID">@entity.DepartmentName</a></td>
                <td><a href="Role?ID=@entity.RoleID">@entity.RoleName</a></td>
                <td class="text-center">
                    <i class="bi bi-@(entity.Online ? "check-lg" : "x-lg") text-@(entity.Online ? "success" : "danger")"></i>
                </td>
                <td class="text-center">
                    <i class="bi bi-@(entity.Enable ? "check-lg" : "x-lg") text-@(entity.Enable ? "success" : "danger")"></i>
                </td>
                <td class="text-right">@entity.Logins.ToString("n0")</td>
                <td>@entity.LastLogin.ToFullString("")</td>
                <td title="@entity.LastLoginAddress">@entity.LastLoginIP</td>
                <td>@Html.ActionLink("链接", "Index", "UserConnect", new { UserID = entity.ID }, null)</td>
                <td>@Html.ActionLink("日志", "Index", "Log", new { UserID = entity.ID }, null)</td>

                @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
                {
                    <td class="text-center w-80px" style="min-width:60px;">
                        @Html.Partial("_List_Data_Action", (Object)entity)
                    </td>
                }
            </tr>
        }
    </tbody>
</table>